package middleware

import (
	"grpc.getaway.adminspro.padmins.com/internal/api/module/admin/container"
)

func CorsMiddleware(c *container.Context) bool {
	c.Response.HeaderSet("Access-Control-Allow-Origin", "*")
	c.Response.HeaderSet("Access-Control-Allow-methods", "POST, PUT, GET, OPTIONS, DELETE")
	c.Response.HeaderSet("Access-Control-Allow-Credentials", "true")
	c.Response.HeaderSet("Access-Control-Allow-Headers", "X-Requested-With,X_Requested_With,Authorization,Content-Type,token,access-token")
	c.Response.HeaderSet("Content-Type", "application/json;charset=utf-8")
	if c.Request.Method() == "OPTIONS" {
		c.Write("Options Request!")
		return false
	}
	return true
}
